<template>
  <div class="dashboard-editor-container">

    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <el-row>
      <el-col :span="6">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>志诚泰和spring cloud 开发框架V1.0</span>
          
          </div>

          <div id="myHelloWord">
            <div><span>{{ user_name }}</span></div>
          </div>

          <el-timeline>
            <el-timeline-item v-for="(activity, index) in activities2" :key="index" :icon="activity.icon" :type="activity.type" :color="activity.color" :size="activity.size" :timestamp="activity.timestamp">
              {{activity.content}}
            </el-timeline-item>
          </el-timeline>
        </el-card>

      </el-col>

      <el-col :span="16" :offset="2">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>{{chartName}}</span>
          </div>
          <line-chart :chart-data="lineChartData" />
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'
const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}
export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    LineChart
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      activities2: [],
      chartName: "访客",
      user_name: JSON.parse(sessionStorage.getItem('userinfo')).nickname,
    }
  },
  methods: {
    handleSetLineChartData(type) {
      if (type === "newVisitis") {
        this.chartName = "访客"
      } else if (type === "messages") {
        this.chartName = "消息"
      } else if (type === "purchases") {
        this.chartName = "活动"
      } else if (type === "shoppings") {
        this.chartName = "记录"
      }
      this.lineChartData = lineChartData[type]
    },
    goGithub() {
      location.href = ''
    }
  }
}

</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}
</style>
